package Pointers;

import Script.Offset;
import interfaces.Pointer;
import interfaces.PointerFactory;

/**
 * Used to instantiate new pointer objects, while
 * hiding the pointer type from the user.
 * 
 * @author Tobias Edin
 */
public class JPointerFactory implements PointerFactory{
	public enum PointerType {_2Byte_littleEndian};
	private PointerType type;
	
	public JPointerFactory(PointerType type) {
		this.type = type;
	}
	
	@Override
	public Pointer newPointer(int position, Offset offset, Offset fileOffset) {
		switch (type) {
			case _2Byte_littleEndian:
				return new SnesPointer(position, offset, fileOffset);
			default:
				return null;
		}
	}

	@Override
	public void setType(PointerType type) {
		this.type = type;
	}

	@Override
	public int pointerSize() {
		switch (type) {
		case _2Byte_littleEndian:
			return 2;
		default:
			return -1;
		}
	}

}
